import Vue from 'vue'
import VueRouter from 'vue-router'

// 导入组件     
// import Home from '../views/Home.vue'
import Carts from '../views/carts/Carts.vue'
import CartsMain1 from '../views/carts/CartsMain1.vue'
import CartsMain2 from '../views/carts/CartsMain2.vue'

// 新增组件 
import Login from '../views/users/Login.vue'
import Admin from '../views/admin/Admin.vue'
import Welcome from '../views/admin/Welcome.vue'

Vue.use(VueRouter)

const routes = [
  // { path: '/', name: 'Home', component: Home },
  { 
    path: '/', 
    component: Admin,
    children: [
        {path: 'welcome', alias: '/', component: Welcome}
    ]
  },
  { path: '/login', name: 'login', component: Login },
  {
    path: '/carts',
    component: Carts,
    // name,
    children: [
      {path: 'main1', component: CartsMain1},
      {path: 'main2', component: CartsMain2},
    ]
  },
  {
    path: '/about',
    name: 'About',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
